﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace Maticsoft.DAL
{
    /// <summary>
    /// 数据访问类:SO_SODetails
    /// </summary>
    public partial class SO_SODetails
    {
        public SO_SODetails()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int AutoID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from SO_SODetails");
            strSql.Append(" where AutoID=@AutoID");
            SqlParameter[] parameters = {
                    new SqlParameter("@AutoID", SqlDbType.Int,4)
            };
            parameters[0].Value = AutoID;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.SO_SODetails model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SO_SODetails(");
            strSql.Append("cSOCode,cInvCode,dPreDate,iQuantity,iNum,iQuotedPrice,iUnitPrice,iTaxUnitPrice,iMoney,iTax,iSum,iDisCount,iNatUnitPrice,iNatMoney,iNatTax,iNatSum,iNatDisCount,iFHNum,iFHQuantity,iFHMoney,iKPQuantity,iKPNum,iKPMoney,cMemo,cFree1,cFree2,bFH,iSOsID,KL,KL2,cInvName,iTaxRate,cDefine22,cDefine23,cDefine24,cDefine25,cDefine26,cDefine27,cItemCode,cItem_class,cItemName,cItem_CName,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,iInvExchRate,cUnitID,ID,cDefine28,cDefine29,cDefine30,cDefine31,cDefine32,cDefine33,cDefine34,cDefine35,cDefine36,cDefine37,FPurQuan,fSaleCost,fSalePrice,cQuoCode,iQuoID,cSCloser,dPreMoDate,iRowNo,iCusBomID,iMoQuantity,cContractID,cContractTagCode,cContractRowGuid,iPPartSeqID,iPPartID,iPPartQty,cCusInvCode,cCusInvName,iPreKeepQuantity,iPreKeepNum,iPreKeepTotQuantity,iPreKeepTotNum,dreleasedate,fcusminprice,fimquantity,fomquantity,ballpurchase,finquantity,icostquantity,icostsum,foutquantity,foutnum,iexchsum,imoneysum,iaoids,cpreordercode,fretquantity,fretnum,dbclosedate,dbclosesystime,bOrderBOM,bOrderBOMOver,idemandtype,cdemandcode,cdemandmemo,fPurSum,fPurBillQty,fPurBillSum,iimid,ccorvouchtype,icorrowno,busecusbom,body_outid,fVeriDispQty,fVeriDispSum)");
            strSql.Append(" values (");
            strSql.Append("@cSOCode,@cInvCode,@dPreDate,@iQuantity,@iNum,@iQuotedPrice,@iUnitPrice,@iTaxUnitPrice,@iMoney,@iTax,@iSum,@iDisCount,@iNatUnitPrice,@iNatMoney,@iNatTax,@iNatSum,@iNatDisCount,@iFHNum,@iFHQuantity,@iFHMoney,@iKPQuantity,@iKPNum,@iKPMoney,@cMemo,@cFree1,@cFree2,@bFH,@iSOsID,@KL,@KL2,@cInvName,@iTaxRate,@cDefine22,@cDefine23,@cDefine24,@cDefine25,@cDefine26,@cDefine27,@cItemCode,@cItem_class,@cItemName,@cItem_CName,@cFree3,@cFree4,@cFree5,@cFree6,@cFree7,@cFree8,@cFree9,@cFree10,@iInvExchRate,@cUnitID,@ID,@cDefine28,@cDefine29,@cDefine30,@cDefine31,@cDefine32,@cDefine33,@cDefine34,@cDefine35,@cDefine36,@cDefine37,@FPurQuan,@fSaleCost,@fSalePrice,@cQuoCode,@iQuoID,@cSCloser,@dPreMoDate,@iRowNo,@iCusBomID,@iMoQuantity,@cContractID,@cContractTagCode,@cContractRowGuid,@iPPartSeqID,@iPPartID,@iPPartQty,@cCusInvCode,@cCusInvName,@iPreKeepQuantity,@iPreKeepNum,@iPreKeepTotQuantity,@iPreKeepTotNum,@dreleasedate,@fcusminprice,@fimquantity,@fomquantity,@ballpurchase,@finquantity,@icostquantity,@icostsum,@foutquantity,@foutnum,@iexchsum,@imoneysum,@iaoids,@cpreordercode,@fretquantity,@fretnum,@dbclosedate,@dbclosesystime,@bOrderBOM,@bOrderBOMOver,@idemandtype,@cdemandcode,@cdemandmemo,@fPurSum,@fPurBillQty,@fPurBillSum,@iimid,@ccorvouchtype,@icorrowno,@busecusbom,@body_outid,@fVeriDispQty,@fVeriDispSum)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@cSOCode", SqlDbType.NVarChar,30),
                    new SqlParameter("@cInvCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@dPreDate", SqlDbType.DateTime),
                    new SqlParameter("@iQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iQuotedPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iTaxUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iMoney", SqlDbType.Money,8),
                    new SqlParameter("@iTax", SqlDbType.Money,8),
                    new SqlParameter("@iSum", SqlDbType.Money,8),
                    new SqlParameter("@iDisCount", SqlDbType.Money,8),
                    new SqlParameter("@iNatUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iNatMoney", SqlDbType.Money,8),
                    new SqlParameter("@iNatTax", SqlDbType.Money,8),
                    new SqlParameter("@iNatSum", SqlDbType.Money,8),
                    new SqlParameter("@iNatDisCount", SqlDbType.Money,8),
                    new SqlParameter("@iFHNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iFHQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iFHMoney", SqlDbType.Money,8),
                    new SqlParameter("@iKPQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iKPNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iKPMoney", SqlDbType.Money,8),
                    new SqlParameter("@cMemo", SqlDbType.NVarChar,60),
                    new SqlParameter("@cFree1", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree2", SqlDbType.NVarChar,20),
                    new SqlParameter("@bFH", SqlDbType.Int,4),
                    new SqlParameter("@iSOsID", SqlDbType.Int,4),
                    new SqlParameter("@KL", SqlDbType.Decimal,17),
                    new SqlParameter("@KL2", SqlDbType.Decimal,17),
                    new SqlParameter("@cInvName", SqlDbType.NVarChar,255),
                    new SqlParameter("@iTaxRate", SqlDbType.Decimal,17),
                    new SqlParameter("@cDefine22", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine23", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine24", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine25", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine26", SqlDbType.Float,8),
                    new SqlParameter("@cDefine27", SqlDbType.Float,8),
                    new SqlParameter("@cItemCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@cItem_class", SqlDbType.NVarChar,10),
                    new SqlParameter("@cItemName", SqlDbType.NVarChar,255),
                    new SqlParameter("@cItem_CName", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree3", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree4", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree5", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree6", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree7", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree8", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree9", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree10", SqlDbType.NVarChar,20),
                    new SqlParameter("@iInvExchRate", SqlDbType.Decimal,13),
                    new SqlParameter("@cUnitID", SqlDbType.NVarChar,35),
                    new SqlParameter("@ID", SqlDbType.Int,4),
                    new SqlParameter("@cDefine28", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine29", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine30", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine31", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine32", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine33", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine34", SqlDbType.Int,4),
                    new SqlParameter("@cDefine35", SqlDbType.Int,4),
                    new SqlParameter("@cDefine36", SqlDbType.DateTime),
                    new SqlParameter("@cDefine37", SqlDbType.DateTime),
                    new SqlParameter("@FPurQuan", SqlDbType.Decimal,13),
                    new SqlParameter("@fSaleCost", SqlDbType.Decimal,17),
                    new SqlParameter("@fSalePrice", SqlDbType.Decimal,17),
                    new SqlParameter("@cQuoCode", SqlDbType.NVarChar,30),
                    new SqlParameter("@iQuoID", SqlDbType.Int,4),
                    new SqlParameter("@cSCloser", SqlDbType.NVarChar,20),
                    new SqlParameter("@dPreMoDate", SqlDbType.DateTime),
                    new SqlParameter("@iRowNo", SqlDbType.Int,4),
                    new SqlParameter("@iCusBomID", SqlDbType.Int,4),
                    new SqlParameter("@iMoQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@cContractID", SqlDbType.NVarChar,64),
                    new SqlParameter("@cContractTagCode", SqlDbType.NVarChar,150),
                    new SqlParameter("@cContractRowGuid", SqlDbType.UniqueIdentifier,16),
                    new SqlParameter("@iPPartSeqID", SqlDbType.Int,4),
                    new SqlParameter("@iPPartID", SqlDbType.Int,4),
                    new SqlParameter("@iPPartQty", SqlDbType.Decimal,13),
                    new SqlParameter("@cCusInvCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@cCusInvName", SqlDbType.NVarChar,100),
                    new SqlParameter("@iPreKeepQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepNum", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepTotQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepTotNum", SqlDbType.Decimal,13),
                    new SqlParameter("@dreleasedate", SqlDbType.DateTime),
                    new SqlParameter("@fcusminprice", SqlDbType.Decimal,13),
                    new SqlParameter("@fimquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@fomquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@ballpurchase", SqlDbType.Bit,1),
                    new SqlParameter("@finquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@icostquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@icostsum", SqlDbType.Money,8),
                    new SqlParameter("@foutquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@foutnum", SqlDbType.Decimal,13),
                    new SqlParameter("@iexchsum", SqlDbType.Money,8),
                    new SqlParameter("@imoneysum", SqlDbType.Money,8),
                    new SqlParameter("@iaoids", SqlDbType.Int,4),
                    new SqlParameter("@cpreordercode", SqlDbType.NVarChar,30),
                    new SqlParameter("@fretquantity", SqlDbType.Decimal,17),
                    new SqlParameter("@fretnum", SqlDbType.Decimal,17),
                    new SqlParameter("@dbclosedate", SqlDbType.DateTime),
                    new SqlParameter("@dbclosesystime", SqlDbType.DateTime),
                    new SqlParameter("@bOrderBOM", SqlDbType.Bit,1),
                    new SqlParameter("@bOrderBOMOver", SqlDbType.TinyInt,1),
                    new SqlParameter("@idemandtype", SqlDbType.SmallInt,2),
                    new SqlParameter("@cdemandcode", SqlDbType.NVarChar,40),
                    new SqlParameter("@cdemandmemo", SqlDbType.NVarChar,300),
                    new SqlParameter("@fPurSum", SqlDbType.Decimal,13),
                    new SqlParameter("@fPurBillQty", SqlDbType.Decimal,13),
                    new SqlParameter("@fPurBillSum", SqlDbType.Decimal,13),
                    new SqlParameter("@iimid", SqlDbType.BigInt,8),
                    new SqlParameter("@ccorvouchtype", SqlDbType.NVarChar,10),
                    new SqlParameter("@icorrowno", SqlDbType.Int,4),
                    new SqlParameter("@busecusbom", SqlDbType.Bit,1),
                    new SqlParameter("@body_outid", SqlDbType.UniqueIdentifier,16),
                    new SqlParameter("@fVeriDispQty", SqlDbType.Decimal,13),
                    new SqlParameter("@fVeriDispSum", SqlDbType.Money,8)};
            parameters[0].Value = model.cSOCode;
            parameters[1].Value = model.cInvCode;
            parameters[2].Value = model.dPreDate;
            parameters[3].Value = model.iQuantity;
            parameters[4].Value = model.iNum;
            parameters[5].Value = model.iQuotedPrice;
            parameters[6].Value = model.iUnitPrice;
            parameters[7].Value = model.iTaxUnitPrice;
            parameters[8].Value = model.iMoney;
            parameters[9].Value = model.iTax;
            parameters[10].Value = model.iSum;
            parameters[11].Value = model.iDisCount;
            parameters[12].Value = model.iNatUnitPrice;
            parameters[13].Value = model.iNatMoney;
            parameters[14].Value = model.iNatTax;
            parameters[15].Value = model.iNatSum;
            parameters[16].Value = model.iNatDisCount;
            parameters[17].Value = model.iFHNum;
            parameters[18].Value = model.iFHQuantity;
            parameters[19].Value = model.iFHMoney;
            parameters[20].Value = model.iKPQuantity;
            parameters[21].Value = model.iKPNum;
            parameters[22].Value = model.iKPMoney;
            parameters[23].Value = model.cMemo;
            parameters[24].Value = model.cFree1;
            parameters[25].Value = model.cFree2;
            parameters[26].Value = model.bFH;
            parameters[27].Value = model.iSOsID;
            parameters[28].Value = model.KL;
            parameters[29].Value = model.KL2;
            parameters[30].Value = model.cInvName;
            parameters[31].Value = model.iTaxRate;
            parameters[32].Value = model.cDefine22;
            parameters[33].Value = model.cDefine23;
            parameters[34].Value = model.cDefine24;
            parameters[35].Value = model.cDefine25;
            parameters[36].Value = model.cDefine26;
            parameters[37].Value = model.cDefine27;
            parameters[38].Value = model.cItemCode;
            parameters[39].Value = model.cItem_class;
            parameters[40].Value = model.cItemName;
            parameters[41].Value = model.cItem_CName;
            parameters[42].Value = model.cFree3;
            parameters[43].Value = model.cFree4;
            parameters[44].Value = model.cFree5;
            parameters[45].Value = model.cFree6;
            parameters[46].Value = model.cFree7;
            parameters[47].Value = model.cFree8;
            parameters[48].Value = model.cFree9;
            parameters[49].Value = model.cFree10;
            parameters[50].Value = model.iInvExchRate;
            parameters[51].Value = model.cUnitID;
            parameters[52].Value = model.ID;
            parameters[53].Value = model.cDefine28;
            parameters[54].Value = model.cDefine29;
            parameters[55].Value = model.cDefine30;
            parameters[56].Value = model.cDefine31;
            parameters[57].Value = model.cDefine32;
            parameters[58].Value = model.cDefine33;
            parameters[59].Value = model.cDefine34;
            parameters[60].Value = model.cDefine35;
            parameters[61].Value = model.cDefine36;
            parameters[62].Value = model.cDefine37;
            parameters[63].Value = model.FPurQuan;
            parameters[64].Value = model.fSaleCost;
            parameters[65].Value = model.fSalePrice;
            parameters[66].Value = model.cQuoCode;
            parameters[67].Value = model.iQuoID;
            parameters[68].Value = model.cSCloser;
            parameters[69].Value = model.dPreMoDate;
            parameters[70].Value = model.iRowNo;
            parameters[71].Value = model.iCusBomID;
            parameters[72].Value = model.iMoQuantity;
            parameters[73].Value = model.cContractID;
            parameters[74].Value = model.cContractTagCode;
            parameters[75].Value = Guid.NewGuid();
            parameters[76].Value = model.iPPartSeqID;
            parameters[77].Value = model.iPPartID;
            parameters[78].Value = model.iPPartQty;
            parameters[79].Value = model.cCusInvCode;
            parameters[80].Value = model.cCusInvName;
            parameters[81].Value = model.iPreKeepQuantity;
            parameters[82].Value = model.iPreKeepNum;
            parameters[83].Value = model.iPreKeepTotQuantity;
            parameters[84].Value = model.iPreKeepTotNum;
            parameters[85].Value = model.dreleasedate;
            parameters[86].Value = model.fcusminprice;
            parameters[87].Value = model.fimquantity;
            parameters[88].Value = model.fomquantity;
            parameters[89].Value = model.ballpurchase;
            parameters[90].Value = model.finquantity;
            parameters[91].Value = model.icostquantity;
            parameters[92].Value = model.icostsum;
            parameters[93].Value = model.foutquantity;
            parameters[94].Value = model.foutnum;
            parameters[95].Value = model.iexchsum;
            parameters[96].Value = model.imoneysum;
            parameters[97].Value = model.iaoids;
            parameters[98].Value = model.cpreordercode;
            parameters[99].Value = model.fretquantity;
            parameters[100].Value = model.fretnum;
            parameters[101].Value = model.dbclosedate;
            parameters[102].Value = model.dbclosesystime;
            parameters[103].Value = model.bOrderBOM;
            parameters[104].Value = model.bOrderBOMOver;
            parameters[105].Value = model.idemandtype;
            parameters[106].Value = model.cdemandcode;
            parameters[107].Value = model.cdemandmemo;
            parameters[108].Value = model.fPurSum;
            parameters[109].Value = model.fPurBillQty;
            parameters[110].Value = model.fPurBillSum;
            parameters[111].Value = model.iimid;
            parameters[112].Value = model.ccorvouchtype;
            parameters[113].Value = model.icorrowno;
            parameters[114].Value = model.busecusbom;
            parameters[115].Value = Guid.NewGuid();
            parameters[116].Value = model.fVeriDispQty;
            parameters[117].Value = model.fVeriDispSum;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SO_SODetails model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SO_SODetails set ");
            strSql.Append("cSOCode=@cSOCode,");
            strSql.Append("cInvCode=@cInvCode,");
            strSql.Append("dPreDate=@dPreDate,");
            strSql.Append("iQuantity=@iQuantity,");
            strSql.Append("iNum=@iNum,");
            strSql.Append("iQuotedPrice=@iQuotedPrice,");
            strSql.Append("iUnitPrice=@iUnitPrice,");
            strSql.Append("iTaxUnitPrice=@iTaxUnitPrice,");
            strSql.Append("iMoney=@iMoney,");
            strSql.Append("iTax=@iTax,");
            strSql.Append("iSum=@iSum,");
            strSql.Append("iDisCount=@iDisCount,");
            strSql.Append("iNatUnitPrice=@iNatUnitPrice,");
            strSql.Append("iNatMoney=@iNatMoney,");
            strSql.Append("iNatTax=@iNatTax,");
            strSql.Append("iNatSum=@iNatSum,");
            strSql.Append("iNatDisCount=@iNatDisCount,");
            strSql.Append("iFHNum=@iFHNum,");
            strSql.Append("iFHQuantity=@iFHQuantity,");
            strSql.Append("iFHMoney=@iFHMoney,");
            strSql.Append("iKPQuantity=@iKPQuantity,");
            strSql.Append("iKPNum=@iKPNum,");
            strSql.Append("iKPMoney=@iKPMoney,");
            strSql.Append("cMemo=@cMemo,");
            strSql.Append("cFree1=@cFree1,");
            strSql.Append("cFree2=@cFree2,");
            strSql.Append("bFH=@bFH,");
            strSql.Append("iSOsID=@iSOsID,");
            strSql.Append("KL=@KL,");
            strSql.Append("KL2=@KL2,");
            strSql.Append("cInvName=@cInvName,");
            strSql.Append("iTaxRate=@iTaxRate,");
            strSql.Append("cDefine22=@cDefine22,");
            strSql.Append("cDefine23=@cDefine23,");
            strSql.Append("cDefine24=@cDefine24,");
            strSql.Append("cDefine25=@cDefine25,");
            strSql.Append("cDefine26=@cDefine26,");
            strSql.Append("cDefine27=@cDefine27,");
            strSql.Append("cItemCode=@cItemCode,");
            strSql.Append("cItem_class=@cItem_class,");
            strSql.Append("cItemName=@cItemName,");
            strSql.Append("cItem_CName=@cItem_CName,");
            strSql.Append("cFree3=@cFree3,");
            strSql.Append("cFree4=@cFree4,");
            strSql.Append("cFree5=@cFree5,");
            strSql.Append("cFree6=@cFree6,");
            strSql.Append("cFree7=@cFree7,");
            strSql.Append("cFree8=@cFree8,");
            strSql.Append("cFree9=@cFree9,");
            strSql.Append("cFree10=@cFree10,");
            strSql.Append("iInvExchRate=@iInvExchRate,");
            strSql.Append("cUnitID=@cUnitID,");
            strSql.Append("ID=@ID,");
            strSql.Append("cDefine28=@cDefine28,");
            strSql.Append("cDefine29=@cDefine29,");
            strSql.Append("cDefine30=@cDefine30,");
            strSql.Append("cDefine31=@cDefine31,");
            strSql.Append("cDefine32=@cDefine32,");
            strSql.Append("cDefine33=@cDefine33,");
            strSql.Append("cDefine34=@cDefine34,");
            strSql.Append("cDefine35=@cDefine35,");
            strSql.Append("cDefine36=@cDefine36,");
            strSql.Append("cDefine37=@cDefine37,");
            strSql.Append("FPurQuan=@FPurQuan,");
            strSql.Append("fSaleCost=@fSaleCost,");
            strSql.Append("fSalePrice=@fSalePrice,");
            strSql.Append("cQuoCode=@cQuoCode,");
            strSql.Append("iQuoID=@iQuoID,");
            strSql.Append("cSCloser=@cSCloser,");
            strSql.Append("dPreMoDate=@dPreMoDate,");
            strSql.Append("iRowNo=@iRowNo,");
            strSql.Append("iCusBomID=@iCusBomID,");
            strSql.Append("iMoQuantity=@iMoQuantity,");
            strSql.Append("cContractID=@cContractID,");
            strSql.Append("cContractTagCode=@cContractTagCode,");
            strSql.Append("cContractRowGuid=@cContractRowGuid,");
            strSql.Append("iPPartSeqID=@iPPartSeqID,");
            strSql.Append("iPPartID=@iPPartID,");
            strSql.Append("iPPartQty=@iPPartQty,");
            strSql.Append("cCusInvCode=@cCusInvCode,");
            strSql.Append("cCusInvName=@cCusInvName,");
            strSql.Append("iPreKeepQuantity=@iPreKeepQuantity,");
            strSql.Append("iPreKeepNum=@iPreKeepNum,");
            strSql.Append("iPreKeepTotQuantity=@iPreKeepTotQuantity,");
            strSql.Append("iPreKeepTotNum=@iPreKeepTotNum,");
            strSql.Append("dreleasedate=@dreleasedate,");
            strSql.Append("fcusminprice=@fcusminprice,");
            strSql.Append("fimquantity=@fimquantity,");
            strSql.Append("fomquantity=@fomquantity,");
            strSql.Append("ballpurchase=@ballpurchase,");
            strSql.Append("finquantity=@finquantity,");
            strSql.Append("icostquantity=@icostquantity,");
            strSql.Append("icostsum=@icostsum,");
            strSql.Append("foutquantity=@foutquantity,");
            strSql.Append("foutnum=@foutnum,");
            strSql.Append("iexchsum=@iexchsum,");
            strSql.Append("imoneysum=@imoneysum,");
            strSql.Append("iaoids=@iaoids,");
            strSql.Append("cpreordercode=@cpreordercode,");
            strSql.Append("fretquantity=@fretquantity,");
            strSql.Append("fretnum=@fretnum,");
            strSql.Append("dbclosedate=@dbclosedate,");
            strSql.Append("dbclosesystime=@dbclosesystime,");
            strSql.Append("bOrderBOM=@bOrderBOM,");
            strSql.Append("bOrderBOMOver=@bOrderBOMOver,");
            strSql.Append("idemandtype=@idemandtype,");
            strSql.Append("cdemandcode=@cdemandcode,");
            strSql.Append("cdemandmemo=@cdemandmemo,");
            strSql.Append("fPurSum=@fPurSum,");
            strSql.Append("fPurBillQty=@fPurBillQty,");
            strSql.Append("fPurBillSum=@fPurBillSum,");
            strSql.Append("iimid=@iimid,");
            strSql.Append("ccorvouchtype=@ccorvouchtype,");
            strSql.Append("icorrowno=@icorrowno,");
            strSql.Append("busecusbom=@busecusbom,");
            strSql.Append("body_outid=@body_outid,");
            strSql.Append("fVeriDispQty=@fVeriDispQty,");
            strSql.Append("fVeriDispSum=@fVeriDispSum");
            strSql.Append(" where AutoID=@AutoID");
            SqlParameter[] parameters = {
                    new SqlParameter("@cSOCode", SqlDbType.NVarChar,30),
                    new SqlParameter("@cInvCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@dPreDate", SqlDbType.DateTime),
                    new SqlParameter("@iQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iQuotedPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iTaxUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iMoney", SqlDbType.Money,8),
                    new SqlParameter("@iTax", SqlDbType.Money,8),
                    new SqlParameter("@iSum", SqlDbType.Money,8),
                    new SqlParameter("@iDisCount", SqlDbType.Money,8),
                    new SqlParameter("@iNatUnitPrice", SqlDbType.Decimal,17),
                    new SqlParameter("@iNatMoney", SqlDbType.Money,8),
                    new SqlParameter("@iNatTax", SqlDbType.Money,8),
                    new SqlParameter("@iNatSum", SqlDbType.Money,8),
                    new SqlParameter("@iNatDisCount", SqlDbType.Money,8),
                    new SqlParameter("@iFHNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iFHQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iFHMoney", SqlDbType.Money,8),
                    new SqlParameter("@iKPQuantity", SqlDbType.Decimal,17),
                    new SqlParameter("@iKPNum", SqlDbType.Decimal,17),
                    new SqlParameter("@iKPMoney", SqlDbType.Money,8),
                    new SqlParameter("@cMemo", SqlDbType.NVarChar,60),
                    new SqlParameter("@cFree1", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree2", SqlDbType.NVarChar,20),
                    new SqlParameter("@bFH", SqlDbType.Int,4),
                    new SqlParameter("@iSOsID", SqlDbType.Int,4),
                    new SqlParameter("@KL", SqlDbType.Decimal,17),
                    new SqlParameter("@KL2", SqlDbType.Decimal,17),
                    new SqlParameter("@cInvName", SqlDbType.NVarChar,255),
                    new SqlParameter("@iTaxRate", SqlDbType.Decimal,17),
                    new SqlParameter("@cDefine22", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine23", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine24", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine25", SqlDbType.NVarChar,60),
                    new SqlParameter("@cDefine26", SqlDbType.Float,8),
                    new SqlParameter("@cDefine27", SqlDbType.Float,8),
                    new SqlParameter("@cItemCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@cItem_class", SqlDbType.NVarChar,10),
                    new SqlParameter("@cItemName", SqlDbType.NVarChar,255),
                    new SqlParameter("@cItem_CName", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree3", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree4", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree5", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree6", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree7", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree8", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree9", SqlDbType.NVarChar,20),
                    new SqlParameter("@cFree10", SqlDbType.NVarChar,20),
                    new SqlParameter("@iInvExchRate", SqlDbType.Decimal,13),
                    new SqlParameter("@cUnitID", SqlDbType.NVarChar,35),
                    new SqlParameter("@ID", SqlDbType.Int,4),
                    new SqlParameter("@cDefine28", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine29", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine30", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine31", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine32", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine33", SqlDbType.NVarChar,120),
                    new SqlParameter("@cDefine34", SqlDbType.Int,4),
                    new SqlParameter("@cDefine35", SqlDbType.Int,4),
                    new SqlParameter("@cDefine36", SqlDbType.DateTime),
                    new SqlParameter("@cDefine37", SqlDbType.DateTime),
                    new SqlParameter("@FPurQuan", SqlDbType.Decimal,13),
                    new SqlParameter("@fSaleCost", SqlDbType.Decimal,17),
                    new SqlParameter("@fSalePrice", SqlDbType.Decimal,17),
                    new SqlParameter("@cQuoCode", SqlDbType.NVarChar,30),
                    new SqlParameter("@iQuoID", SqlDbType.Int,4),
                    new SqlParameter("@cSCloser", SqlDbType.NVarChar,20),
                    new SqlParameter("@dPreMoDate", SqlDbType.DateTime),
                    new SqlParameter("@iRowNo", SqlDbType.Int,4),
                    new SqlParameter("@iCusBomID", SqlDbType.Int,4),
                    new SqlParameter("@iMoQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@cContractID", SqlDbType.NVarChar,64),
                    new SqlParameter("@cContractTagCode", SqlDbType.NVarChar,150),
                    new SqlParameter("@cContractRowGuid", SqlDbType.UniqueIdentifier,16),
                    new SqlParameter("@iPPartSeqID", SqlDbType.Int,4),
                    new SqlParameter("@iPPartID", SqlDbType.Int,4),
                    new SqlParameter("@iPPartQty", SqlDbType.Decimal,13),
                    new SqlParameter("@cCusInvCode", SqlDbType.NVarChar,60),
                    new SqlParameter("@cCusInvName", SqlDbType.NVarChar,100),
                    new SqlParameter("@iPreKeepQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepNum", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepTotQuantity", SqlDbType.Decimal,13),
                    new SqlParameter("@iPreKeepTotNum", SqlDbType.Decimal,13),
                    new SqlParameter("@dreleasedate", SqlDbType.DateTime),
                    new SqlParameter("@fcusminprice", SqlDbType.Decimal,13),
                    new SqlParameter("@fimquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@fomquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@ballpurchase", SqlDbType.Bit,1),
                    new SqlParameter("@finquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@icostquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@icostsum", SqlDbType.Money,8),
                    new SqlParameter("@foutquantity", SqlDbType.Decimal,13),
                    new SqlParameter("@foutnum", SqlDbType.Decimal,13),
                    new SqlParameter("@iexchsum", SqlDbType.Money,8),
                    new SqlParameter("@imoneysum", SqlDbType.Money,8),
                    new SqlParameter("@iaoids", SqlDbType.Int,4),
                    new SqlParameter("@cpreordercode", SqlDbType.NVarChar,30),
                    new SqlParameter("@fretquantity", SqlDbType.Decimal,17),
                    new SqlParameter("@fretnum", SqlDbType.Decimal,17),
                    new SqlParameter("@dbclosedate", SqlDbType.DateTime),
                    new SqlParameter("@dbclosesystime", SqlDbType.DateTime),
                    new SqlParameter("@bOrderBOM", SqlDbType.Bit,1),
                    new SqlParameter("@bOrderBOMOver", SqlDbType.TinyInt,1),
                    new SqlParameter("@idemandtype", SqlDbType.SmallInt,2),
                    new SqlParameter("@cdemandcode", SqlDbType.NVarChar,40),
                    new SqlParameter("@cdemandmemo", SqlDbType.NVarChar,300),
                    new SqlParameter("@fPurSum", SqlDbType.Decimal,13),
                    new SqlParameter("@fPurBillQty", SqlDbType.Decimal,13),
                    new SqlParameter("@fPurBillSum", SqlDbType.Decimal,13),
                    new SqlParameter("@iimid", SqlDbType.BigInt,8),
                    new SqlParameter("@ccorvouchtype", SqlDbType.NVarChar,10),
                    new SqlParameter("@icorrowno", SqlDbType.Int,4),
                    new SqlParameter("@busecusbom", SqlDbType.Bit,1),
                    new SqlParameter("@body_outid", SqlDbType.UniqueIdentifier,16),
                    new SqlParameter("@fVeriDispQty", SqlDbType.Decimal,13),
                    new SqlParameter("@fVeriDispSum", SqlDbType.Money,8),
                    new SqlParameter("@AutoID", SqlDbType.Int,4)};
            parameters[0].Value = model.cSOCode;
            parameters[1].Value = model.cInvCode;
            parameters[2].Value = model.dPreDate;
            parameters[3].Value = model.iQuantity;
            parameters[4].Value = model.iNum;
            parameters[5].Value = model.iQuotedPrice;
            parameters[6].Value = model.iUnitPrice;
            parameters[7].Value = model.iTaxUnitPrice;
            parameters[8].Value = model.iMoney;
            parameters[9].Value = model.iTax;
            parameters[10].Value = model.iSum;
            parameters[11].Value = model.iDisCount;
            parameters[12].Value = model.iNatUnitPrice;
            parameters[13].Value = model.iNatMoney;
            parameters[14].Value = model.iNatTax;
            parameters[15].Value = model.iNatSum;
            parameters[16].Value = model.iNatDisCount;
            parameters[17].Value = model.iFHNum;
            parameters[18].Value = model.iFHQuantity;
            parameters[19].Value = model.iFHMoney;
            parameters[20].Value = model.iKPQuantity;
            parameters[21].Value = model.iKPNum;
            parameters[22].Value = model.iKPMoney;
            parameters[23].Value = model.cMemo;
            parameters[24].Value = model.cFree1;
            parameters[25].Value = model.cFree2;
            parameters[26].Value = model.bFH;
            parameters[27].Value = model.iSOsID;
            parameters[28].Value = model.KL;
            parameters[29].Value = model.KL2;
            parameters[30].Value = model.cInvName;
            parameters[31].Value = model.iTaxRate;
            parameters[32].Value = model.cDefine22;
            parameters[33].Value = model.cDefine23;
            parameters[34].Value = model.cDefine24;
            parameters[35].Value = model.cDefine25;
            parameters[36].Value = model.cDefine26;
            parameters[37].Value = model.cDefine27;
            parameters[38].Value = model.cItemCode;
            parameters[39].Value = model.cItem_class;
            parameters[40].Value = model.cItemName;
            parameters[41].Value = model.cItem_CName;
            parameters[42].Value = model.cFree3;
            parameters[43].Value = model.cFree4;
            parameters[44].Value = model.cFree5;
            parameters[45].Value = model.cFree6;
            parameters[46].Value = model.cFree7;
            parameters[47].Value = model.cFree8;
            parameters[48].Value = model.cFree9;
            parameters[49].Value = model.cFree10;
            parameters[50].Value = model.iInvExchRate;
            parameters[51].Value = model.cUnitID;
            parameters[52].Value = model.ID;
            parameters[53].Value = model.cDefine28;
            parameters[54].Value = model.cDefine29;
            parameters[55].Value = model.cDefine30;
            parameters[56].Value = model.cDefine31;
            parameters[57].Value = model.cDefine32;
            parameters[58].Value = model.cDefine33;
            parameters[59].Value = model.cDefine34;
            parameters[60].Value = model.cDefine35;
            parameters[61].Value = model.cDefine36;
            parameters[62].Value = model.cDefine37;
            parameters[63].Value = model.FPurQuan;
            parameters[64].Value = model.fSaleCost;
            parameters[65].Value = model.fSalePrice;
            parameters[66].Value = model.cQuoCode;
            parameters[67].Value = model.iQuoID;
            parameters[68].Value = model.cSCloser;
            parameters[69].Value = model.dPreMoDate;
            parameters[70].Value = model.iRowNo;
            parameters[71].Value = model.iCusBomID;
            parameters[72].Value = model.iMoQuantity;
            parameters[73].Value = model.cContractID;
            parameters[74].Value = model.cContractTagCode;
            parameters[75].Value = model.cContractRowGuid;
            parameters[76].Value = model.iPPartSeqID;
            parameters[77].Value = model.iPPartID;
            parameters[78].Value = model.iPPartQty;
            parameters[79].Value = model.cCusInvCode;
            parameters[80].Value = model.cCusInvName;
            parameters[81].Value = model.iPreKeepQuantity;
            parameters[82].Value = model.iPreKeepNum;
            parameters[83].Value = model.iPreKeepTotQuantity;
            parameters[84].Value = model.iPreKeepTotNum;
            parameters[85].Value = model.dreleasedate;
            parameters[86].Value = model.fcusminprice;
            parameters[87].Value = model.fimquantity;
            parameters[88].Value = model.fomquantity;
            parameters[89].Value = model.ballpurchase;
            parameters[90].Value = model.finquantity;
            parameters[91].Value = model.icostquantity;
            parameters[92].Value = model.icostsum;
            parameters[93].Value = model.foutquantity;
            parameters[94].Value = model.foutnum;
            parameters[95].Value = model.iexchsum;
            parameters[96].Value = model.imoneysum;
            parameters[97].Value = model.iaoids;
            parameters[98].Value = model.cpreordercode;
            parameters[99].Value = model.fretquantity;
            parameters[100].Value = model.fretnum;
            parameters[101].Value = model.dbclosedate;
            parameters[102].Value = model.dbclosesystime;
            parameters[103].Value = model.bOrderBOM;
            parameters[104].Value = model.bOrderBOMOver;
            parameters[105].Value = model.idemandtype;
            parameters[106].Value = model.cdemandcode;
            parameters[107].Value = model.cdemandmemo;
            parameters[108].Value = model.fPurSum;
            parameters[109].Value = model.fPurBillQty;
            parameters[110].Value = model.fPurBillSum;
            parameters[111].Value = model.iimid;
            parameters[112].Value = model.ccorvouchtype;
            parameters[113].Value = model.icorrowno;
            parameters[114].Value = model.busecusbom;
            parameters[115].Value = model.body_outid;
            parameters[116].Value = model.fVeriDispQty;
            parameters[117].Value = model.fVeriDispSum;
            parameters[118].Value = model.AutoID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int AutoID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SO_SODetails ");
            strSql.Append(" where AutoID=@AutoID");
            SqlParameter[] parameters = {
                    new SqlParameter("@AutoID", SqlDbType.Int,4)
            };
            parameters[0].Value = AutoID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string AutoIDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SO_SODetails ");
            strSql.Append(" where AutoID in (" + AutoIDlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SO_SODetails GetModel(int AutoID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 AutoID,cSOCode,cInvCode,dPreDate,iQuantity,iNum,iQuotedPrice,iUnitPrice,iTaxUnitPrice,iMoney,iTax,iSum,iDisCount,iNatUnitPrice,iNatMoney,iNatTax,iNatSum,iNatDisCount,iFHNum,iFHQuantity,iFHMoney,iKPQuantity,iKPNum,iKPMoney,cMemo,cFree1,cFree2,bFH,iSOsID,KL,KL2,cInvName,iTaxRate,cDefine22,cDefine23,cDefine24,cDefine25,cDefine26,cDefine27,cItemCode,cItem_class,cItemName,cItem_CName,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,iInvExchRate,cUnitID,ID,cDefine28,cDefine29,cDefine30,cDefine31,cDefine32,cDefine33,cDefine34,cDefine35,cDefine36,cDefine37,FPurQuan,fSaleCost,fSalePrice,cQuoCode,iQuoID,cSCloser,dPreMoDate,iRowNo,iCusBomID,iMoQuantity,cContractID,cContractTagCode,cContractRowGuid,iPPartSeqID,iPPartID,iPPartQty,cCusInvCode,cCusInvName,iPreKeepQuantity,iPreKeepNum,iPreKeepTotQuantity,iPreKeepTotNum,dreleasedate,fcusminprice,fimquantity,fomquantity,ballpurchase,finquantity,icostquantity,icostsum,foutquantity,foutnum,iexchsum,imoneysum,iaoids,cpreordercode,fretquantity,fretnum,dbclosedate,dbclosesystime,bOrderBOM,bOrderBOMOver,idemandtype,cdemandcode,cdemandmemo,fPurSum,fPurBillQty,fPurBillSum,iimid,ccorvouchtype,icorrowno,busecusbom,body_outid,fVeriDispQty,fVeriDispSum from SO_SODetails ");
            strSql.Append(" where AutoID=@AutoID");
            SqlParameter[] parameters = {
                    new SqlParameter("@AutoID", SqlDbType.Int,4)
            };
            parameters[0].Value = AutoID;

            Maticsoft.Model.SO_SODetails model = new Maticsoft.Model.SO_SODetails();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SO_SODetails DataRowToModel(DataRow row)
        {
            Maticsoft.Model.SO_SODetails model = new Maticsoft.Model.SO_SODetails();
            if (row != null)
            {
                if (row["AutoID"] != null && row["AutoID"].ToString() != "")
                {
                    model.AutoID = int.Parse(row["AutoID"].ToString());
                }
                if (row["cSOCode"] != null)
                {
                    model.cSOCode = row["cSOCode"].ToString();
                }
                if (row["cInvCode"] != null)
                {
                    model.cInvCode = row["cInvCode"].ToString();
                }
                if (row["dPreDate"] != null && row["dPreDate"].ToString() != "")
                {
                    model.dPreDate = DateTime.Parse(row["dPreDate"].ToString());
                }
                if (row["iQuantity"] != null && row["iQuantity"].ToString() != "")
                {
                    model.iQuantity = decimal.Parse(row["iQuantity"].ToString());
                }
                if (row["iNum"] != null && row["iNum"].ToString() != "")
                {
                    model.iNum = decimal.Parse(row["iNum"].ToString());
                }
                if (row["iQuotedPrice"] != null && row["iQuotedPrice"].ToString() != "")
                {
                    model.iQuotedPrice = decimal.Parse(row["iQuotedPrice"].ToString());
                }
                if (row["iUnitPrice"] != null && row["iUnitPrice"].ToString() != "")
                {
                    model.iUnitPrice = decimal.Parse(row["iUnitPrice"].ToString());
                }
                if (row["iTaxUnitPrice"] != null && row["iTaxUnitPrice"].ToString() != "")
                {
                    model.iTaxUnitPrice = decimal.Parse(row["iTaxUnitPrice"].ToString());
                }
                if (row["iMoney"] != null && row["iMoney"].ToString() != "")
                {
                    model.iMoney = decimal.Parse(row["iMoney"].ToString());
                }
                if (row["iTax"] != null && row["iTax"].ToString() != "")
                {
                    model.iTax = decimal.Parse(row["iTax"].ToString());
                }
                if (row["iSum"] != null && row["iSum"].ToString() != "")
                {
                    model.iSum = decimal.Parse(row["iSum"].ToString());
                }
                if (row["iDisCount"] != null && row["iDisCount"].ToString() != "")
                {
                    model.iDisCount = decimal.Parse(row["iDisCount"].ToString());
                }
                if (row["iNatUnitPrice"] != null && row["iNatUnitPrice"].ToString() != "")
                {
                    model.iNatUnitPrice = decimal.Parse(row["iNatUnitPrice"].ToString());
                }
                if (row["iNatMoney"] != null && row["iNatMoney"].ToString() != "")
                {
                    model.iNatMoney = decimal.Parse(row["iNatMoney"].ToString());
                }
                if (row["iNatTax"] != null && row["iNatTax"].ToString() != "")
                {
                    model.iNatTax = decimal.Parse(row["iNatTax"].ToString());
                }
                if (row["iNatSum"] != null && row["iNatSum"].ToString() != "")
                {
                    model.iNatSum = decimal.Parse(row["iNatSum"].ToString());
                }
                if (row["iNatDisCount"] != null && row["iNatDisCount"].ToString() != "")
                {
                    model.iNatDisCount = decimal.Parse(row["iNatDisCount"].ToString());
                }
                if (row["iFHNum"] != null && row["iFHNum"].ToString() != "")
                {
                    model.iFHNum = decimal.Parse(row["iFHNum"].ToString());
                }
                if (row["iFHQuantity"] != null && row["iFHQuantity"].ToString() != "")
                {
                    model.iFHQuantity = decimal.Parse(row["iFHQuantity"].ToString());
                }
                if (row["iFHMoney"] != null && row["iFHMoney"].ToString() != "")
                {
                    model.iFHMoney = decimal.Parse(row["iFHMoney"].ToString());
                }
                if (row["iKPQuantity"] != null && row["iKPQuantity"].ToString() != "")
                {
                    model.iKPQuantity = decimal.Parse(row["iKPQuantity"].ToString());
                }
                if (row["iKPNum"] != null && row["iKPNum"].ToString() != "")
                {
                    model.iKPNum = decimal.Parse(row["iKPNum"].ToString());
                }
                if (row["iKPMoney"] != null && row["iKPMoney"].ToString() != "")
                {
                    model.iKPMoney = decimal.Parse(row["iKPMoney"].ToString());
                }
                if (row["cMemo"] != null)
                {
                    model.cMemo = row["cMemo"].ToString();
                }
                if (row["cFree1"] != null)
                {
                    model.cFree1 = row["cFree1"].ToString();
                }
                if (row["cFree2"] != null)
                {
                    model.cFree2 = row["cFree2"].ToString();
                }
                if (row["bFH"] != null && row["bFH"].ToString() != "")
                {
                    model.bFH = int.Parse(row["bFH"].ToString());
                }
                if (row["iSOsID"] != null && row["iSOsID"].ToString() != "")
                {
                    model.iSOsID = int.Parse(row["iSOsID"].ToString());
                }
                if (row["KL"] != null && row["KL"].ToString() != "")
                {
                    model.KL = decimal.Parse(row["KL"].ToString());
                }
                if (row["KL2"] != null && row["KL2"].ToString() != "")
                {
                    model.KL2 = decimal.Parse(row["KL2"].ToString());
                }
                if (row["cInvName"] != null)
                {
                    model.cInvName = row["cInvName"].ToString();
                }
                if (row["iTaxRate"] != null && row["iTaxRate"].ToString() != "")
                {
                    model.iTaxRate = decimal.Parse(row["iTaxRate"].ToString());
                }
                if (row["cDefine22"] != null)
                {
                    model.cDefine22 = row["cDefine22"].ToString();
                }
                if (row["cDefine23"] != null)
                {
                    model.cDefine23 = row["cDefine23"].ToString();
                }
                if (row["cDefine24"] != null)
                {
                    model.cDefine24 = row["cDefine24"].ToString();
                }
                if (row["cDefine25"] != null)
                {
                    model.cDefine25 = row["cDefine25"].ToString();
                }
                if (row["cDefine26"] != null && row["cDefine26"].ToString() != "")
                {
                    model.cDefine26 = decimal.Parse(row["cDefine26"].ToString());
                }
                if (row["cDefine27"] != null && row["cDefine27"].ToString() != "")
                {
                    model.cDefine27 = decimal.Parse(row["cDefine27"].ToString());
                }
                if (row["cItemCode"] != null)
                {
                    model.cItemCode = row["cItemCode"].ToString();
                }
                if (row["cItem_class"] != null)
                {
                    model.cItem_class = row["cItem_class"].ToString();
                }
                if (row["cItemName"] != null)
                {
                    model.cItemName = row["cItemName"].ToString();
                }
                if (row["cItem_CName"] != null)
                {
                    model.cItem_CName = row["cItem_CName"].ToString();
                }
                if (row["cFree3"] != null)
                {
                    model.cFree3 = row["cFree3"].ToString();
                }
                if (row["cFree4"] != null)
                {
                    model.cFree4 = row["cFree4"].ToString();
                }
                if (row["cFree5"] != null)
                {
                    model.cFree5 = row["cFree5"].ToString();
                }
                if (row["cFree6"] != null)
                {
                    model.cFree6 = row["cFree6"].ToString();
                }
                if (row["cFree7"] != null)
                {
                    model.cFree7 = row["cFree7"].ToString();
                }
                if (row["cFree8"] != null)
                {
                    model.cFree8 = row["cFree8"].ToString();
                }
                if (row["cFree9"] != null)
                {
                    model.cFree9 = row["cFree9"].ToString();
                }
                if (row["cFree10"] != null)
                {
                    model.cFree10 = row["cFree10"].ToString();
                }
                if (row["iInvExchRate"] != null && row["iInvExchRate"].ToString() != "")
                {
                    model.iInvExchRate = decimal.Parse(row["iInvExchRate"].ToString());
                }
                if (row["cUnitID"] != null)
                {
                    model.cUnitID = row["cUnitID"].ToString();
                }
                if (row["ID"] != null && row["ID"].ToString() != "")
                {
                    model.ID = int.Parse(row["ID"].ToString());
                }
                if (row["cDefine28"] != null)
                {
                    model.cDefine28 = row["cDefine28"].ToString();
                }
                if (row["cDefine29"] != null)
                {
                    model.cDefine29 = row["cDefine29"].ToString();
                }
                if (row["cDefine30"] != null)
                {
                    model.cDefine30 = row["cDefine30"].ToString();
                }
                if (row["cDefine31"] != null)
                {
                    model.cDefine31 = row["cDefine31"].ToString();
                }
                if (row["cDefine32"] != null)
                {
                    model.cDefine32 = row["cDefine32"].ToString();
                }
                if (row["cDefine33"] != null)
                {
                    model.cDefine33 = row["cDefine33"].ToString();
                }
                if (row["cDefine34"] != null && row["cDefine34"].ToString() != "")
                {
                    model.cDefine34 = int.Parse(row["cDefine34"].ToString());
                }
                if (row["cDefine35"] != null && row["cDefine35"].ToString() != "")
                {
                    model.cDefine35 = int.Parse(row["cDefine35"].ToString());
                }
                if (row["cDefine36"] != null && row["cDefine36"].ToString() != "")
                {
                    model.cDefine36 = DateTime.Parse(row["cDefine36"].ToString());
                }
                if (row["cDefine37"] != null && row["cDefine37"].ToString() != "")
                {
                    model.cDefine37 = DateTime.Parse(row["cDefine37"].ToString());
                }
                if (row["FPurQuan"] != null && row["FPurQuan"].ToString() != "")
                {
                    model.FPurQuan = decimal.Parse(row["FPurQuan"].ToString());
                }
                if (row["fSaleCost"] != null && row["fSaleCost"].ToString() != "")
                {
                    model.fSaleCost = decimal.Parse(row["fSaleCost"].ToString());
                }
                if (row["fSalePrice"] != null && row["fSalePrice"].ToString() != "")
                {
                    model.fSalePrice = decimal.Parse(row["fSalePrice"].ToString());
                }
                if (row["cQuoCode"] != null)
                {
                    model.cQuoCode = row["cQuoCode"].ToString();
                }
                if (row["iQuoID"] != null && row["iQuoID"].ToString() != "")
                {
                    model.iQuoID = int.Parse(row["iQuoID"].ToString());
                }
                if (row["cSCloser"] != null)
                {
                    model.cSCloser = row["cSCloser"].ToString();
                }
                if (row["dPreMoDate"] != null && row["dPreMoDate"].ToString() != "")
                {
                    model.dPreMoDate = DateTime.Parse(row["dPreMoDate"].ToString());
                }
                if (row["iRowNo"] != null && row["iRowNo"].ToString() != "")
                {
                    model.iRowNo = int.Parse(row["iRowNo"].ToString());
                }
                if (row["iCusBomID"] != null && row["iCusBomID"].ToString() != "")
                {
                    model.iCusBomID = int.Parse(row["iCusBomID"].ToString());
                }
                if (row["iMoQuantity"] != null && row["iMoQuantity"].ToString() != "")
                {
                    model.iMoQuantity = decimal.Parse(row["iMoQuantity"].ToString());
                }
                if (row["cContractID"] != null)
                {
                    model.cContractID = row["cContractID"].ToString();
                }
                if (row["cContractTagCode"] != null)
                {
                    model.cContractTagCode = row["cContractTagCode"].ToString();
                }
                if (row["cContractRowGuid"] != null && row["cContractRowGuid"].ToString() != "")
                {
                    model.cContractRowGuid = new Guid(row["cContractRowGuid"].ToString());
                }
                if (row["iPPartSeqID"] != null && row["iPPartSeqID"].ToString() != "")
                {
                    model.iPPartSeqID = int.Parse(row["iPPartSeqID"].ToString());
                }
                if (row["iPPartID"] != null && row["iPPartID"].ToString() != "")
                {
                    model.iPPartID = int.Parse(row["iPPartID"].ToString());
                }
                if (row["iPPartQty"] != null && row["iPPartQty"].ToString() != "")
                {
                    model.iPPartQty = decimal.Parse(row["iPPartQty"].ToString());
                }
                if (row["cCusInvCode"] != null)
                {
                    model.cCusInvCode = row["cCusInvCode"].ToString();
                }
                if (row["cCusInvName"] != null)
                {
                    model.cCusInvName = row["cCusInvName"].ToString();
                }
                if (row["iPreKeepQuantity"] != null && row["iPreKeepQuantity"].ToString() != "")
                {
                    model.iPreKeepQuantity = decimal.Parse(row["iPreKeepQuantity"].ToString());
                }
                if (row["iPreKeepNum"] != null && row["iPreKeepNum"].ToString() != "")
                {
                    model.iPreKeepNum = decimal.Parse(row["iPreKeepNum"].ToString());
                }
                if (row["iPreKeepTotQuantity"] != null && row["iPreKeepTotQuantity"].ToString() != "")
                {
                    model.iPreKeepTotQuantity = decimal.Parse(row["iPreKeepTotQuantity"].ToString());
                }
                if (row["iPreKeepTotNum"] != null && row["iPreKeepTotNum"].ToString() != "")
                {
                    model.iPreKeepTotNum = decimal.Parse(row["iPreKeepTotNum"].ToString());
                }
                if (row["dreleasedate"] != null && row["dreleasedate"].ToString() != "")
                {
                    model.dreleasedate = DateTime.Parse(row["dreleasedate"].ToString());
                }
                if (row["fcusminprice"] != null && row["fcusminprice"].ToString() != "")
                {
                    model.fcusminprice = decimal.Parse(row["fcusminprice"].ToString());
                }
                if (row["fimquantity"] != null && row["fimquantity"].ToString() != "")
                {
                    model.fimquantity = decimal.Parse(row["fimquantity"].ToString());
                }
                if (row["fomquantity"] != null && row["fomquantity"].ToString() != "")
                {
                    model.fomquantity = decimal.Parse(row["fomquantity"].ToString());
                }
                if (row["ballpurchase"] != null && row["ballpurchase"].ToString() != "")
                {
                    if ((row["ballpurchase"].ToString() == "1") || (row["ballpurchase"].ToString().ToLower() == "true"))
                    {
                        model.ballpurchase = true;
                    }
                    else
                    {
                        model.ballpurchase = false;
                    }
                }
                if (row["finquantity"] != null && row["finquantity"].ToString() != "")
                {
                    model.finquantity = decimal.Parse(row["finquantity"].ToString());
                }
                if (row["icostquantity"] != null && row["icostquantity"].ToString() != "")
                {
                    model.icostquantity = decimal.Parse(row["icostquantity"].ToString());
                }
                if (row["icostsum"] != null && row["icostsum"].ToString() != "")
                {
                    model.icostsum = decimal.Parse(row["icostsum"].ToString());
                }
                if (row["foutquantity"] != null && row["foutquantity"].ToString() != "")
                {
                    model.foutquantity = decimal.Parse(row["foutquantity"].ToString());
                }
                if (row["foutnum"] != null && row["foutnum"].ToString() != "")
                {
                    model.foutnum = decimal.Parse(row["foutnum"].ToString());
                }
                if (row["iexchsum"] != null && row["iexchsum"].ToString() != "")
                {
                    model.iexchsum = decimal.Parse(row["iexchsum"].ToString());
                }
                if (row["imoneysum"] != null && row["imoneysum"].ToString() != "")
                {
                    model.imoneysum = decimal.Parse(row["imoneysum"].ToString());
                }
                if (row["iaoids"] != null && row["iaoids"].ToString() != "")
                {
                    model.iaoids = int.Parse(row["iaoids"].ToString());
                }
                if (row["cpreordercode"] != null)
                {
                    model.cpreordercode = row["cpreordercode"].ToString();
                }
                if (row["fretquantity"] != null && row["fretquantity"].ToString() != "")
                {
                    model.fretquantity = decimal.Parse(row["fretquantity"].ToString());
                }
                if (row["fretnum"] != null && row["fretnum"].ToString() != "")
                {
                    model.fretnum = decimal.Parse(row["fretnum"].ToString());
                }
                if (row["dbclosedate"] != null && row["dbclosedate"].ToString() != "")
                {
                    model.dbclosedate = DateTime.Parse(row["dbclosedate"].ToString());
                }
                if (row["dbclosesystime"] != null && row["dbclosesystime"].ToString() != "")
                {
                    model.dbclosesystime = DateTime.Parse(row["dbclosesystime"].ToString());
                }
                if (row["bOrderBOM"] != null && row["bOrderBOM"].ToString() != "")
                {
                    if ((row["bOrderBOM"].ToString() == "1") || (row["bOrderBOM"].ToString().ToLower() == "true"))
                    {
                        model.bOrderBOM = true;
                    }
                    else
                    {
                        model.bOrderBOM = false;
                    }
                }
                if (row["bOrderBOMOver"] != null && row["bOrderBOMOver"].ToString() != "")
                {
                    model.bOrderBOMOver = int.Parse(row["bOrderBOMOver"].ToString());
                }
                if (row["idemandtype"] != null && row["idemandtype"].ToString() != "")
                {
                    model.idemandtype = int.Parse(row["idemandtype"].ToString());
                }
                if (row["cdemandcode"] != null)
                {
                    model.cdemandcode = row["cdemandcode"].ToString();
                }
                if (row["cdemandmemo"] != null)
                {
                    model.cdemandmemo = row["cdemandmemo"].ToString();
                }
                if (row["fPurSum"] != null && row["fPurSum"].ToString() != "")
                {
                    model.fPurSum = decimal.Parse(row["fPurSum"].ToString());
                }
                if (row["fPurBillQty"] != null && row["fPurBillQty"].ToString() != "")
                {
                    model.fPurBillQty = decimal.Parse(row["fPurBillQty"].ToString());
                }
                if (row["fPurBillSum"] != null && row["fPurBillSum"].ToString() != "")
                {
                    model.fPurBillSum = decimal.Parse(row["fPurBillSum"].ToString());
                }
                if (row["iimid"] != null && row["iimid"].ToString() != "")
                {
                    model.iimid = long.Parse(row["iimid"].ToString());
                }
                if (row["ccorvouchtype"] != null)
                {
                    model.ccorvouchtype = row["ccorvouchtype"].ToString();
                }
                if (row["icorrowno"] != null && row["icorrowno"].ToString() != "")
                {
                    model.icorrowno = int.Parse(row["icorrowno"].ToString());
                }
                if (row["busecusbom"] != null && row["busecusbom"].ToString() != "")
                {
                    if ((row["busecusbom"].ToString() == "1") || (row["busecusbom"].ToString().ToLower() == "true"))
                    {
                        model.busecusbom = true;
                    }
                    else
                    {
                        model.busecusbom = false;
                    }
                }
                if (row["body_outid"] != null && row["body_outid"].ToString() != "")
                {
                    model.body_outid = new Guid(row["body_outid"].ToString());
                }
                if (row["fVeriDispQty"] != null && row["fVeriDispQty"].ToString() != "")
                {
                    model.fVeriDispQty = decimal.Parse(row["fVeriDispQty"].ToString());
                }
                if (row["fVeriDispSum"] != null && row["fVeriDispSum"].ToString() != "")
                {
                    model.fVeriDispSum = decimal.Parse(row["fVeriDispSum"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select AutoID,cSOCode,cInvCode,dPreDate,iQuantity,iNum,iQuotedPrice,iUnitPrice,iTaxUnitPrice,iMoney,iTax,iSum,iDisCount,iNatUnitPrice,iNatMoney,iNatTax,iNatSum,iNatDisCount,iFHNum,iFHQuantity,iFHMoney,iKPQuantity,iKPNum,iKPMoney,cMemo,cFree1,cFree2,bFH,iSOsID,KL,KL2,cInvName,iTaxRate,cDefine22,cDefine23,cDefine24,cDefine25,cDefine26,cDefine27,cItemCode,cItem_class,cItemName,cItem_CName,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,iInvExchRate,cUnitID,ID,cDefine28,cDefine29,cDefine30,cDefine31,cDefine32,cDefine33,cDefine34,cDefine35,cDefine36,cDefine37,FPurQuan,fSaleCost,fSalePrice,cQuoCode,iQuoID,cSCloser,dPreMoDate,iRowNo,iCusBomID,iMoQuantity,cContractID,cContractTagCode,cContractRowGuid,iPPartSeqID,iPPartID,iPPartQty,cCusInvCode,cCusInvName,iPreKeepQuantity,iPreKeepNum,iPreKeepTotQuantity,iPreKeepTotNum,dreleasedate,fcusminprice,fimquantity,fomquantity,ballpurchase,finquantity,icostquantity,icostsum,foutquantity,foutnum,iexchsum,imoneysum,iaoids,cpreordercode,fretquantity,fretnum,dbclosedate,dbclosesystime,bOrderBOM,bOrderBOMOver,idemandtype,cdemandcode,cdemandmemo,fPurSum,fPurBillQty,fPurBillSum,iimid,ccorvouchtype,icorrowno,busecusbom,body_outid,fVeriDispQty,fVeriDispSum ");
            strSql.Append(" FROM SO_SODetails ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" AutoID,cSOCode,cInvCode,dPreDate,iQuantity,iNum,iQuotedPrice,iUnitPrice,iTaxUnitPrice,iMoney,iTax,iSum,iDisCount,iNatUnitPrice,iNatMoney,iNatTax,iNatSum,iNatDisCount,iFHNum,iFHQuantity,iFHMoney,iKPQuantity,iKPNum,iKPMoney,cMemo,cFree1,cFree2,bFH,iSOsID,KL,KL2,cInvName,iTaxRate,cDefine22,cDefine23,cDefine24,cDefine25,cDefine26,cDefine27,cItemCode,cItem_class,cItemName,cItem_CName,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,iInvExchRate,cUnitID,ID,cDefine28,cDefine29,cDefine30,cDefine31,cDefine32,cDefine33,cDefine34,cDefine35,cDefine36,cDefine37,FPurQuan,fSaleCost,fSalePrice,cQuoCode,iQuoID,cSCloser,dPreMoDate,iRowNo,iCusBomID,iMoQuantity,cContractID,cContractTagCode,cContractRowGuid,iPPartSeqID,iPPartID,iPPartQty,cCusInvCode,cCusInvName,iPreKeepQuantity,iPreKeepNum,iPreKeepTotQuantity,iPreKeepTotNum,dreleasedate,fcusminprice,fimquantity,fomquantity,ballpurchase,finquantity,icostquantity,icostsum,foutquantity,foutnum,iexchsum,imoneysum,iaoids,cpreordercode,fretquantity,fretnum,dbclosedate,dbclosesystime,bOrderBOM,bOrderBOMOver,idemandtype,cdemandcode,cdemandmemo,fPurSum,fPurBillQty,fPurBillSum,iimid,ccorvouchtype,icorrowno,busecusbom,body_outid,fVeriDispQty,fVeriDispSum ");
            strSql.Append(" FROM SO_SODetails ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM SO_SODetails ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.AutoID desc");
            }
            strSql.Append(")AS Row, T.*  from SO_SODetails T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "SO_SODetails";
			parameters[1].Value = "AutoID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

